<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.usernet.product.tools.AdminRight"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="resources/css/style.css">
		<script src="resources/js/comm.js"></script>
		<script src="resources/js/jquery-1.4.min.js"></script>
		<script type="text/javascript">
			function checkForm(){
				submitForm('queryform');
			}
			// sort
			function changeSort(id,old){
				var sort = $("#input_"+id).val();
				if(!checkNum(sort)){
					alert("请输入数字");
					$("#input_"+id).attr("value",old);
				}else{
					if(sort!=old){
						$("#btn_ok_"+id).attr({"disabled":"disabled"});
						$("#btn_ok_"+id).attr("value","处理中");
						$.ajax({
							type : "POST",
							url : "software.do",
							dataType : "text",
							data : {
								method : "doSort",
								id : id,
								sort : sort
							},
							success : function(result){
								if(result==1){
									hideSort(id);
									$("#input_"+id).attr("value",sort);
									$("#span_"+id).text(sort);
								}else{
									hideSort(id);
									alert("修改失败");
								}
								$("#btn_ok_"+id).removeAttr("disabled");
								$("#btn_ok_"+id).attr("value","确定");
							}
						});
					}else{
						hideSort(id);
						$("#input_"+id).attr("value",sort);
						$("#span_"+id).text(sort);
					}
				}
			}
			function showSort(id){
				if(${admin.flag}!=<%=String.valueOf(AdminRight.supers) %>){alert("没有权限");return;}
				$("#span_"+id).css("display","none");
				$("#input_"+id).css("display","block");
				$("#btn_ok_"+id).css("display","block");
				$("#btn_cancle_"+id).css("display","block");
			}
			function hideSort(id){
				$("#span_"+id).css("display","block");
				$("#input_"+id).css("display","none");
				$("#btn_ok_"+id).css("display","none");
				$("#btn_cancle_"+id).css("display","none");
			}
			// tops
			function changeTops(id,old){
				var sort = $("#input_tops_"+id).val();
				if(sort==-1){
					alert("请选择一项");
				}else{
					if(sort!=old){
						$("#btn_ok_tops_"+id).attr({"disabled":"disabled"});
						$("#btn_ok_tops_"+id).attr("value","处理中");
						$.ajax({
							type : "POST",
							url : "software.do",
							dataType : "text",
							data : {
								method : "doTops",
								id : id,
								tops : sort
							},
							success : function(result){
								if(result==1){
									hideTops(id);
									if(sort=="0")
										$("#span_tops_"+id).text("不推荐,不顶置");
									if(sort=="1")
										$("#span_tops_"+id).text("推荐");
									if(sort=="2"){
										$("#span_tops_"+id).text("顶置");
									    $("#input_tops_"+id).val(sort);
									}
								}else{
									hideTops(id);
									alert("修改失败");
								}
								$("#btn_ok_tops_"+id).removeAttr("disabled");
								$("#btn_ok_tops_"+id).attr("value","确定");
							}
						});
						}else{
							hideTops(id);
							if(sort=="0")
								$("#span_tops_"+id).text("不推荐,不顶置");
							if(sort=="1")
								$("#span_tops_"+id).text("推荐");
							if(sort=="2"){
								$("#span_tops_"+id).text("顶置");
							    $("#input_tops_"+id).val(sort);
							}
						}
				}
			}
			function showTops(id){
				if(${admin.flag}!=<%=String.valueOf(AdminRight.supers) %>){alert("没有权限");return;}
				$("#span_tops_"+id).css("display","none");
				$("#input_tops_"+id).css("display","block");
				$("#btn_ok_tops_"+id).css("display","block");
				$("#btn_cancle_tops_"+id).css("display","block");
			}
			function hideTops(id){
				$("#span_tops_"+id).css("display","block");
				$("#input_tops_"+id).css("display","none");
				$("#btn_ok_tops_"+id).css("display","none");
				$("#btn_cancle_tops_"+id).css("display","none");
			}
			function copyMsg(name,msg){
				window.clipboardData.setData('text',msg);
				alert("已经复制到了剪切板\n"+name+"\n"+msg);
			}
		</script>

	</head>
	<body onkeydown="if(event.keyCode==27) return false;">
		<jsp:include page="../inc/header.jsp"></jsp:include>
		<form id="queryform" action="software.do" method="post">
		<input type="hidden" name="method" value="toList">
		<input type="hidden" id="pageNo" name="pageNo" value="${page.currentPage }">
		<input type="hidden" id="pageSize" name="pageSize" value="${page.everyPage}">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="resources/images/other/tab_05.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_03.gif" width="12"
									height="30" />
							</td>
							<td>
								<div class="page_title">
									<img align="middle" src="resources/images/other/tb.gif"
										width="16" height="16" />
									 软件信息管理
								</div>
							</td>
							<td>
								<div class="button_bar">
									<input value="添加软件" type="button" class="common_button"
										onclick="javascript:location='software.do?method=toAdd1';loading();">
									<input value="查询" type="button" class="common_button" onclick="checkForm();loading();">
									<input value="刷新" type="button" class="common_button"
										onclick="checkForm();loading();">
								</div>
							</td>
							<td width="16">
								<img src="resources/images/other/tab_07.gif" width="16"
									height="30" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="8" background="resources/images/other/tab_12.gif">
							</td>
							<td>
								<table cellspacing="1" cellpadding="0" class="query_form_table">
									<tr>
										<th>
											软件名称(可拼音搜索)
										</th>
										<td>
											<input style="width: 80%" id="softName" name="softName" value="${form.softName }" />
										</td>
										<th>
											所属分类
										</th>
										<td>
											<select name="typeIds" id="typeIds" style="width: 80%">
												<option value="-1">--请选择--</option>
												<logic:iterate id="type" name="typeList">
													<option
													<logic:equal value="${type.id }" name="form" property="typeIds">selected</logic:equal> value="${type.id }">${type.name }</option>
												</logic:iterate>
											</select>
										</td>
									</tr>
									<tr>
										<th>
											是否可用
										</th>
										<td>
											<select id="isUsed" name="isUsed" style="width: 80%">
												<option value="-1">--请选择--</option>
													<option value="1"
													<logic:equal value="1" name="form" property="isUsed">
													selected
													</logic:equal>>锁定</option>
													<option value="0"
													<logic:equal value="0" name="form" property="isUsed">
													selected
													</logic:equal>>可用</option>
											</select>
										</td>
										<th>
											所属主题
										</th>
										<td>
											<select name="resIds" id="resIds" style="width: 80%">
												<option value="-1">--请选择--</option>
												<logic:iterate id="res" name="resourcesList">
													<option
													<logic:equal value="${res.id }" name="form" property="resIds">selected</logic:equal> value="${res.id }">${res.name }</option>
												</logic:iterate>
											</select>
										</td>
									</tr>
									<tr>
										<th>
											是否顶置
										</th>
										<td>
											<select id="isTops" name="isTops" style="width: 80%">
												<option value="-1">--请选择--</option>
													<option value="0"
													<logic:equal value="0" name="form" property="isTops">
													selected
													</logic:equal>>不推荐,不顶置</option>
													<option value="1"
													<logic:equal value="1" name="form" property="isTops">
													selected
													</logic:equal>>推荐</option>
													<option value="2"
													<logic:equal value="2" name="form" property="isTops">
													selected
													</logic:equal>>顶置</option>
											</select>
										</td>
										<th>
											是否收费
										</th>
										<td>
											<select id="isMoney" name="isMoney" style="width: 80%">
												<option value="-1">--请选择--</option>
													<option value="1"
													<logic:equal value="1" name="form" property="isMoney">
													selected
													</logic:equal>>收费</option>
													<option value="0"
													<logic:equal value="0" name="form" property="isMoney">
													selected
													</logic:equal>>免费</option>
											</select>
											<button class="common_button" onclick="$('#softName').val('');$('#typeIds').val('-1');$('#resIds').val('-1');$('#isTops').val('-1');$('#isMoney').val('-1');$('#isUsed').val('-1');checkForm();loading();">清空</button>
										</td>
									</tr>
								</table>
								<br />
								<table cellspacing="1" cellpadding="0" class="data_list_table">
									<tr>
										<th>
											软件名称
										</th>
										<th>
											版本
										</th>
										<th>
											版本号
										</th>
										<th>
											支持版本
										</th>
										<th>
											推荐顺序
										</th>
										<th>
											是否顶置
										</th>
										<th>
											大小
										</th>
										<th>
											评分
										</th>
										<th>
											所属专题
										</th>
										<th>
											所属分类
										</th>
										<th>
											下载次数
										</th>
										<th>
											状态
										</th>
										<th>
											操作
										</th>
									</tr>
									<logic:present name="list">
										<logic:iterate id="item" name="list">
											<tr onclick="clickto();" onmousemove="changeto();"
												onmouseout="changeback();">
												<td class="list_data_number">
													${item.name }
												</td>
												<td class="list_data_ltext">
													${item.version }
												</td>
												<td class="list_data_number">
													${item.code }
												</td>
												<td class="list_data_ltext">
													${item.sdk }
												</td>
												<td title="双击修改推荐顺序" class="list_data_ltext" ondblclick="showSort(${item.id})">
													<span id="span_${item.id }">${item.recommend }</span>
													<input style="display: none;width: 50px;" id="input_${item.id }" value="${item.recommend }"/>
													<button style="display: none;" id="btn_ok_${item.id }" class="common_button" onclick="changeSort(${item.id},'${item.recommend }');">确定</button>
													<button style="display: none;" id="btn_cancle_${item.id }" class="common_button" onclick="hideSort(${item.id});">取消</button>
												</td>
												<td title="双击修改推荐顺序" class="list_data_ltext" ondblclick="showTops(${item.id})">
													<!-- 不推荐和不顶置：0推荐：1；顶置：2 -->
													<logic:equal value="0" name="item" property="tops">
														<span id="span_tops_${item.id }">不推荐,不顶置</span>
													</logic:equal>
													<logic:equal value="1" name="item" property="tops">
														<span id="span_tops_${item.id }">推荐</span>
													</logic:equal>
													<logic:equal value="2" name="item" property="tops">
														<span id="span_tops_${item.id }">顶置</span>
													</logic:equal>
													<select style="display: none;width: 100px;" id="input_tops_${item.id }">
														<option value="-1">-请选择-</option>
														<option value="0"
														<logic:equal value="0" name="item" property="tops">
														selected
														</logic:equal>>不推荐,不顶置</option>
														<option value="1"
														<logic:equal value="1" name="item" property="tops">
														selected
														</logic:equal>>推荐</option>
														<option value="2"
														<logic:equal value="2" name="item" property="tops">
														selected
														</logic:equal>>顶置</option>
													</select>
													<button style="display: none;" id="btn_ok_tops_${item.id }" class="common_button" onclick="changeTops(${item.id},'${item.tops }');">确定</button>
													<button style="display: none;" id="btn_cancle_tops_${item.id }" class="common_button" onclick="hideTops(${item.id});">取消</button>
												</td>
												<td class="list_data_ltext">
													${item.size }
												</td>
												<td class="list_data_ltext">
													<logic:equal value="0" name="item" property="avg">
														☆☆☆☆☆
													</logic:equal>
													<logic:equal value="1" name="item" property="avg">
														★☆☆☆☆
													</logic:equal>
													<logic:equal value="2" name="item" property="avg">
														★★☆☆☆
													</logic:equal>
													<logic:equal value="3" name="item" property="avg">
														★★★☆☆
													</logic:equal>
													<logic:equal value="4" name="item" property="avg">
														★★★★☆
													</logic:equal>
													<logic:equal value="5" name="item" property="avg">
														★★★★★
													</logic:equal>
												</td>
												<td class="list_data_ltext">
													${item.resources.name }
												</td>
												<td class="list_data_ltext">
													${item.type.name }
												</td>
												<td class="list_data_ltext">
													${item.count }
												</td>
												<td class="list_data_ltext">
													<logic:equal value="0" name="item" property="status">
														<span class="red_star">可用</span>
													</logic:equal>
													<logic:equal value="1" name="item" property="status">
														<span class="red_star">锁定</span>
													</logic:equal>
												</td>
												<td class="list_data_op">
													<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="javascript:location='software.do?method=toUpdate&id=${item.id }';loading();"
														title="编辑" src="resources/images/bt_edit.gif"
														class="op_button" />
													<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="location='software.do?method=toPhoto&id=${item.id}';loading();"
														title="查看/修改/添加/删除/截图" src="resources/images/bt_orders.gif"
														class="op_button" />
													<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="location='software.do?method=toAPK&id=${item.id}';loading();"
														title="重新上传APK" src="resources/images/bt_acti.gif"
														class="op_button" />
													<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="location='software.do?method=toICON&id=${item.id}';loading();"
														title="重新上传ICON" src="resources/images/bt_plan.gif"
														class="op_button" />
													<logic:equal value="0" name="item" property="status">
														<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="javascript:if(window.confirm('确认锁定吗?')){location='software.do?method=doCancle&id=${item.id}';loading();}"
														title="锁定" src="resources/images/bt_deal.gif"
														class="op_button" />
													</logic:equal>
													<!-- 
													<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="copyMsg('${item.name}','<bean:message key="base"/>down.do?id=${item.id }')"
														title="复制下载地址" src="resources/images/bt_feedback.gif"
														class="op_button" />
													 -->
													<logic:equal value="<%=String.valueOf(AdminRight.supers) %>" name="admin" property="flag">
													<logic:equal value="1" name="item" property="status">
														<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="javascript:if(window.confirm('确认解锁吗?')){location='software.do?method=doOk&id=${item.id}';loading();}"
														title="解锁" src="resources/images/bt_yes.gif"
														class="op_button" />
													</logic:equal>
													</logic:equal>
													<logic:equal value="<%=String.valueOf(AdminRight.supers) %>" name="admin" property="flag">
													<img onmousemove="mover(this);" onmouseout="mout(this);"
														onclick="javascript:if(window.confirm('确认删除吗?')){location='software.do?method=doDelete&id=${item.id}';loading();}"
														title="删除" src="resources/images/bt_del.gif"
														class="op_button" />
													</logic:equal>
												</td>
											</tr>
										</logic:iterate>
									</logic:present>
									<logic:notPresent name="list">
										<tr>
											<td colspan="15" class="list_data_text">
												<font color="red">当前没有任何信息</font>
											</td>
										</tr>
									</logic:notPresent>
								</table>
							</td>
							<td width="8" background="resources/images/other/tab_15.gif">
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="35" background="resources/images/other/tab_19.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_18.gif" width="12"
									height="35" />
							</td>
							<td>
								<div class="pager">
									共${page.totalCount }条记录 每页
									<select
										onchange="changePageSize(this.value);">
										<logic:iterate id="size" name="size">
											<option value="${size }"
												<logic:equal value="${size}" name="page" property="everyPage">
									selected
									</logic:equal>>
												${size }
											</option>
										</logic:iterate>

									</select>
									条 第
									<input value="${page.currentPage }" size="2" />
									页/共${page.totalPage }页
									<a
										href="javascript:changePage(1,${page.totalPage},${page.everyPage})">第一页</a>
									<a
										href="javascript:changePage(${page.currentPage-1},${page.totalPage},${page.everyPage})">上一页</a>
									<a
										href="javascript:changePage(${page.currentPage+1},${page.totalPage},${page.everyPage})">下一页</a>
									<a
										href="javascript:changePage(${page.totalPage},${page.totalPage},${page.everyPage})">最后一页</a>
									转到
									<input id="goto" size="2" />
									页
									<button width="20" class="common_button"
										onclick="changePage('goto',${page.totalPage},${page.everyPage});">
										GO
									</button>
								</div>
							</td>
							<td width="16">
								<img src="resources/images/other/tab_20.gif" width="16"
									height="35" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	</body>
</html>
<jsp:include page="../inc/footer.jsp"></jsp:include>